/**
 * MessageJob.java
 * Created at 2018-2-23
 * Created by zhanghailin
 * Copyright (C) 2018 BROADTEXT SOFTWARE, All rights reserved.
 */
package com.broadtext.message.job;

import com.broadtext.common.exp.DaoException;
import com.broadtext.message.service.IEmailService;
import com.broadtext.message.service.IMessageService;
import com.broadtext.message.service.ISmsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

/**
 * <p>ClassName: MessageJob</p>
 * <p>Description: TODO</p>
 * <p>Author: zhanghailin</p>
 * <p>Date: 2018-2-23</p>
 */
public class MessageJob {
    
    /**
     * 日志
     */
    private static Logger logger = LoggerFactory.getLogger(MessageJob.class);
    
    /**
     * 消息服务类
     */
    @Autowired
    @Qualifier("messageService")
    private IMessageService messageService;

    @Autowired
    @Qualifier("emailService")
    private IEmailService emailService;

    @Autowired
    @Qualifier("smsService")
    private ISmsService smsService;
    
    /**
     * 
     * <p>Description: 结转告警数据</p>
     */
    public void insertAlertData() {
        logger.info("begin insert alert data !!!");
        try {
            this.messageService.insertAlertData();
        } catch (DaoException e) {
            logger.error("insert alert data error !!!", e);
        }
        logger.info("end insert alert data !!!");
    }
    
    /**
     * 
     * <p>Description: 结转告警通知数据</p>
     */
    public void insertAlertMessageData() {
        logger.info("begin insert alert message data !!!");
        try {
            this.messageService.insertAlertMessage();
        } catch (DaoException e) {
            logger.error("insert alert message data error !!!", e);
        }
        logger.info("end insert alert message data !!!");
    }
    
    /**
     * 
     * <p>Description: 推送消息至app</p>
     */
    public void pushMessage2App() {
        logger.info("begin push message to app !!!");
        try {
            this.messageService.pushMessage2App();
        } catch (Exception e) {
            logger.error("push message error !!!", e);
        } 
        logger.info("end push message  !!!");
    }

    /**
     *
     * <p>Description: 推送短信</p>
     */
    public void sendSms() {
        logger.info("begin push sms !!!");
        try {
            this.smsService.sendSms();
        } catch (Exception e) {
            logger.error("push sms error !!!", e);
        }
        logger.info("end push sms  !!!");
    }

    /**
     *
     * <p>Description: 推送email</p>
     */
    public void sendEmail() {
        logger.info("begin push email !!!");
        try {
            this.emailService.sendEmail();
        } catch (Exception e) {
            logger.error("push message email !!!", e);
        }
        logger.info("end push email  !!!");
    }
    

}
